package com.community.web.controller.plot;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.community.body.domain.ZyOwnerRoomRecord;
import com.community.body.dto.RecordDTO;
import com.community.body.service.IZyOwnerRoomRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.community.common.annotation.Log;
import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.common.enums.BusinessType;
import com.community.common.utils.poi.ExcelUtil;
import com.community.common.core.page.TableDataInfo;

/**
 * 房屋绑定记录 Controller
 * 
 * @author community
 * @date 2024-04-12
 */
@RestController
@RequestMapping("/plot/record")
public class ZyOwnerRoomRecordController extends BaseController
{
    @Autowired
    private IZyOwnerRoomRecordService zyOwnerRoomRecordService;

    /**
     * 查询房屋绑定记录 列表
     */
    @PreAuthorize("@ss.hasPermi('plot:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZyOwnerRoomRecord zyOwnerRoomRecord)
    {
        List<RecordDTO> list = zyOwnerRoomRecordService.selectZyOwnerRoomRecordList(zyOwnerRoomRecord);
        return getDataTable(list);
    }

    /**
     * 导出房屋绑定记录 列表
     */
//    @PreAuthorize("@ss.hasPermi('plot:record:export')")
//    @Log(title = "房屋绑定记录 ", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ZyOwnerRoomRecord zyOwnerRoomRecord)
//    {
//        List<ZyOwnerRoomRecord> list = zyOwnerRoomRecordService.selectZyOwnerRoomRecordList(zyOwnerRoomRecord);
//        ExcelUtil<ZyOwnerRoomRecord> util = new ExcelUtil<ZyOwnerRoomRecord>(ZyOwnerRoomRecord.class);
//        util.exportExcel(response, list, "房屋绑定记录 数据");
//    }

    /**
     * 获取房屋绑定记录 详细信息
     */
    @PreAuthorize("@ss.hasPermi('plot:record:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(zyOwnerRoomRecordService.selectZyOwnerRoomRecordByRecordId(recordId));
    }

    /**
     * 新增房屋绑定记录 
     */
    @PreAuthorize("@ss.hasPermi('plot:record:add')")
    @Log(title = "房屋绑定记录 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZyOwnerRoomRecord zyOwnerRoomRecord)
    {
        return toAjax(zyOwnerRoomRecordService.insertZyOwnerRoomRecord(zyOwnerRoomRecord));
    }

    @PreAuthorize("@ss.hasPermi('plot:record:insert')")
    @Log(title = "房屋绑定记录 ", businessType = BusinessType.INSERT)
    @PostMapping("insert")
    public AjaxResult insert(@RequestBody ZyOwnerRoomRecord zyOwnerRoomRecord)
    {
        return toAjax(zyOwnerRoomRecordService.insertZyOwnerRoomRecord1(zyOwnerRoomRecord));
    }

    /**
     * 修改房屋绑定记录 
     */
    @PreAuthorize("@ss.hasPermi('plot:record:edit')")
    @Log(title = "房屋绑定记录 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZyOwnerRoomRecord zyOwnerRoomRecord)
    {
        return toAjax(zyOwnerRoomRecordService.updateZyOwnerRoomRecord(zyOwnerRoomRecord));
    }

    /**
     * 删除房屋绑定记录 
     */
    @PreAuthorize("@ss.hasPermi('plot:record:remove')")
    @Log(title = "房屋绑定记录 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(zyOwnerRoomRecordService.deleteZyOwnerRoomRecordByRecordIds(recordIds));
    }
}
